﻿using ST.WX.Common.Enums;
using System;

namespace ST.WX.Common
{
	/// <summary>
	/// 应用相关配置信息
	/// </summary>
	public class WXAppConfig
	{
		/// <summary>
		/// App名称
		/// </summary>
		public string AppName { get; set; }

		/// <summary>
		/// App介绍
		/// </summary>
		public string AppDesc { get; set; }

		/// <summary>
		/// AppID
		/// </summary>
		public readonly string AppID;

		/// <summary>
		/// App密钥
		/// </summary>
		public readonly string AppSecret;

		/// <summary>
		/// 令牌
		/// </summary>
		public readonly string AppToken;

		/// <summary>
		/// 消息加密密钥
		/// </summary>
		public readonly string EncodingAESKey;

		/// <summary>
		/// 商户ID
		/// </summary>
		public readonly string MchID;

		/// <summary>
		/// 商户支付密钥
		/// </summary>
		public readonly string MchKey;

		/// <summary>
		/// APP类型
		/// </summary>
		public readonly WXAppType AppType;

		/// <summary>
		/// 支付结果通知回调url，用于商户接收支付结果
		/// </summary>
		public readonly string NotifyUrl = "https://js.nanjingruike.com/api/wx/notify";

		/// <summary>
		/// 商户系统后台机器IP（可手动配置也可在程序中自动获取）
		/// </summary>
		public readonly string SvrIP = "58.218.211.15";

		/// <summary>
		/// APP配置的后台域名
		/// </summary>
		public readonly string Domain;

		/// <summary>
		/// 代理服务器设置，默认IP和端口号分别为0.0.0.0和0，此时不开启代理（如有需要才设置），格式为（http://10.152.18.220:8080）
		/// </summary>
		public readonly string ProxyUrl;

		/// <summary>
		/// 证书的绝对路径（仅退款、撤销订单时需要），证书文件不能放在web服务器虚拟目录，应放在有访问权限控制的目录中
		/// </summary>
		public readonly string SslCertPath;

		/// <summary>
		/// 证书的密码（仅退款、撤销订单时需要）
		/// </summary>
		public readonly string SslCertPasswd;

		/// <summary>
		/// 测速上报等级（0：关闭上报，1：仅错误时上报，2：全量上报）
		/// </summary>
		public readonly int ReportLevel = 1;

		/// <summary>
		/// 日志等级（0：不输出日志，1：只输出错误信息，2：输出错误和正常信息，3：输出错误信息、正常信息和调试信息）
		/// </summary>
		public readonly int LogLevel = 3;

		public WXAppConfig(string appID, string appSecret, string appToken, string encodingAESKey, string mchID, string mchKey, WXAppType appType, string domain)
		{
			AppID = appID;
			AppSecret = appSecret;
			AppToken = appToken;
			EncodingAESKey = encodingAESKey;
			MchID = mchID;
			MchKey = mchKey;
			AppType = appType;
			Domain = domain;
		}

		public WXAppConfig(string appID, string appSecret, WXAppType appType, string domain)
		{
			AppID = appID;
			AppSecret = appSecret;
			AppType = appType;
			Domain = domain;
		}

		public WXAppConfig(string appID, string appSecret, string appToken, string encodingAESKey, WXAppType appType, string domain)
		{
			AppID = appID;
			AppSecret = appSecret;
			AppToken = appToken;
			EncodingAESKey = encodingAESKey;
			AppType = appType;
			Domain = domain;
		}
	}
}
